package db.tables;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;

import com.db.Table;

import db.beans.M_LanuageBean;

public class M_LanguageTable extends Table {

	public static final String TABLE_NAME = "M_LANGUAGE";
	public static final String COL_LANGUAGE_ID = "LANGUAGE_ID";
	public static final String COL_LANGUAGE_NAME= "LANGUAGE_NAME";

	public static M_LanuageBean[] selectAll(Connection conn) throws SQLException {
		final String sql = "SELECT "
				+ COL_LANGUAGE_ID + ","
				+ COL_LANGUAGE_NAME
				+ " FROM " + TABLE_NAME;
		PreparedStatement stmt = null;
		ResultSet rs = null;
		Vector<M_LanuageBean> v = new Vector<M_LanuageBean>();
		try {
			stmt = conn.prepareStatement(sql);
			rs = stmt.executeQuery();
			int i;
			while (rs.next()) {
				i = 0;
				M_LanuageBean rec = new M_LanuageBean();
				rec.setLanguageId(rs.getInt(++i));
				rec.setLanguageName(rs.getString(++i));
				v.add(rec);
			}
		} finally {
			if (rs != null) {
				rs.close();
			}

			if (stmt != null) {
				stmt.close();
			}
		}
		return (M_LanuageBean[]) v.toArray(new M_LanuageBean[v.size()]);
	}
}
